import React from 'react'
import { Table, Modal, Radio, Tag, message } from 'antd';
import { Action, AuthButton, TableCard } from 'components';
const TableList = ({ dataSource, setDataSource }) => {
    


 

    return (
        <div>
            <TableCard
                rowKey="Cabinet"
                dataSource={dataSource}

            >
                <Table.Column title="区号" dataIndex="area" />
                <Table.Column title="区域" dataIndex="region" render={info => (
                    <div>{info == 1 ? "男宾" : "女宾"}</div>

                )} />
                <Table.Column title="柜号" dataIndex="Cabinet" />

                <Table.Column title="柜类型" dataIndex="type" render={info => {
                    console.log(info)
                    if (info == "1") {
                        return <div>更衣柜</div>
                    } else if (info == "2") {
                        return <div >鞋柜</div>
                    }
                }} />
                <Table.Column title="柜品种" dataIndex="variety" render={info => {

                    if (info == "1") {
                        return <Tag color="blue">不带NFC</Tag>
                    } else if (info == "2") {
                        return <Tag color="red">将军不下马</Tag>
                    } else {
                        return <Tag color="green">带NFC</Tag>
                    }
                }} />

                <Table.Column width={180} title="操作" render={info => (
                    <Action>

                        <Action.Button  >编辑</Action.Button>
                        <Action.Button danger

                            onClick={() => {
                                const cabinetToDelete = info.Cabinet;

                                setDataSource(prevData => {
                                    return prevData.filter(item => item.Cabinet !== cabinetToDelete);
                             
                        
                                });
                            }}
                        >删除</Action.Button>
                    </Action>
                )} />
            </TableCard>
        </div>
    )
}

export default TableList